package com.deep.stream.provider.service.impl;

import com.deep.stream.provider.service.MessageProvider;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;

import javax.annotation.Resource;
import java.util.UUID;

/**
 * @author deeprado
 */
@EnableBinding(Source.class)
public class MessageProviderImpl implements MessageProvider {
    @Resource
    private MessageChannel output;

    @Override
    public String send() {
        final String s = UUID.randomUUID().toString();
        System.out.println(s);
        output.send(MessageBuilder.withPayload(s).build());
        return "ok";
    }
}
